package com.gedi.data.InputFormate.DBInputFormate;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.Iterator;

/**
 * @Author:RenPu
 * @Date: 2020/1/13 11:52
 * @Version: 1.0
 * @description:
 */
public class OrderReduce extends Reducer<Text,DoubleWritable,Text,DoubleWritable> {


    @Override
    protected void reduce(Text key, Iterable<DoubleWritable> values, Context context) throws IOException, InterruptedException {
        double sum=0.0D;
        Iterator<DoubleWritable> iterator = values.iterator();
        while (iterator.hasNext()){
            DoubleWritable next = iterator.next();
            sum +=next.get();
        }
        context.write(key,new DoubleWritable(sum));

    }
}
